#pragma once

#include <chrono>
#include <ctime>
#include <iostream>
#include <string>

#define DEBUG_REDIS 1

namespace mini_redis {

inline std::string nowTime()
{
    using namespace std::chrono;
    auto t = system_clock::to_time_t(system_clock::now());
    char buf[64];
    std::strftime(buf, sizeof(buf), "%F %T", std::localtime(&t));
    return std::string(buf);
}

#if DEBUG_REDIS

#define MR_LOG(level, msg)                                                \
    do                                                                    \
    {                                                                     \
        std::cerr << "[" << nowTime() << "] [" << level << "] " << msg    \
                  << std::endl;                                           \
    } while (0)

#else

#define MR_LOG(level, msg)

#endif

}    // namespace mini_redis
